package com.springcloud.user_sso.controller;

import com.springcloud.user_sso.entity.User;
import com.springcloud.user_sso.service.SsoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * com.springcloud.user_sso.controller;
 * 功能：;
 *
 * @author 李冉 Email:1828581413@qq.com
 * Time:2018/4/5 21:03
 */
@RestController
public class SsoControlller {
    @Autowired
    private SsoService ssoService;

    @GetMapping("/login/{username}/{password}")
    public Map userLogin(@PathVariable("username") String usrename, @PathVariable("password") String password) {
        Map map = new HashMap();
        User user = ssoService.checkUser(usrename, password);
        if (user == null || user.getId() == null) {
            map.put("mes", "登录失败");
            map.put("user", user);
        } else {
            map.put("mes", "登录成功");
            map.put("user", user);
        }
        return map;
    }

}
